<?php

class Default_Model_Categories extends Zend_Db_Table_Abstract
{
    protected $_name = 'categories';
    public function getAllData(){
        $query = $this->select()
                        ->from($this->_name)
                        ->order('ord DESC')
                        ->order('catId ASC');
        return $this->fetchAll($query);
    }
    public function getDataByParentId($parentId){
        $query = $this->select()
                        ->from($this->_name)
                        ->where('parentId = ?', $parentId)
                        ->order('ord DESC')
                        ->order('catId ASC');
        return $this->fetchAll($query);
    }
    public function getDataById($catId){
    	$query = $this->select()
                        ->from($this->_name)
                        ->where('catId = ?',$catId);
        return $this->fetchRow($query);
    }
    public function getCategories()
    {
        $sql = "CALL GetHierarchyCategories()";
        $categories = $this->getDefaultAdapter()->query($sql);
        $stmt = $categories->fetchAll(PDO::FETCH_OBJ);
        return $stmt;
    }
}

























